<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>块级作用域</title>
</head>
<body>
    <script>
        // 每个块级作用域会开辟一个新的内存空间，所以这两个a互不影响
        {
            let a = 1;
        }
        {
            let a = 2;
        }


        // var没有块级作用域的特性，会把它放到全局中
        {
            var b = 3;
        }
        {
            const b = 4;
        }
        console.log(b);
    </script>
</body>
</html>